﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace QLKS
{
    class XuLyInHoaDon
    {
        #region Variable
        private List<string> lstr_stt = new List<string>();
        private List<string> lstr_khachhang = new List<string>();
        private List<string> lstr_loaikhach = new List<string>();
        private List<string> lstr_cmnd = new List<string>();
        private List<string> lstr_diachi = new List<string>();
        private List<string> tatcakh = new List<string>();
        #endregion

        #region Properties
        public List<string> Tatcakh
        {
            get { return tatcakh; }
            set { tatcakh = value; }
        }
        public List<string> Lstr_stt
        {
            get { return lstr_stt; }
            set { lstr_stt = value; }
        }
        public List<string> Lstr_khachhang
        {
            get { return lstr_khachhang; }
            set { lstr_khachhang = value; }
        }
        public List<string> Lstr_loaikhach
        {
            get { return lstr_loaikhach; }
            set { lstr_loaikhach = value; }
        }
        public List<string> Lstr_cmnd
        {
            get { return lstr_cmnd; }
            set { lstr_cmnd = value; }
        }
        public List<string> Lstr_diachi
        {
            get { return lstr_diachi; }
            set { lstr_diachi = value; }
        }
        #endregion

        /// <summary>
        /// Lấy thông tin tất cả các khách hàng cùng thuê chung phòng
        /// </summary>
        public void XuLyHienThi()
        {
            try
            {
                LayDuLieu dl = new LayDuLieu();
                for (int i = 0; i < tatcakh.Count; i++)
                {
                    SqlDataReader dr1 = dl.LayTruongDuLieu("SELECT TenKH FROM KHACHHANG WHERE MaKH='" + tatcakh[i] + "'");
                    while (dr1.Read())
                    {
                        lstr_khachhang.Add(dr1.GetString(0));
                    }
                    XuLyCapNhatKhachHang xlcnkh = new XuLyCapNhatKhachHang();
                    SqlDataReader dr2 = dl.LayTruongDuLieu("SELECT MaLK FROM KHACHHANG WHERE MaKH='" + tatcakh[i] + "'");
                    while (dr2.Read())
                    {
                        lstr_loaikhach.Add(xlcnkh.MaLoaiKhach_LoaiKhachHang(dr2.GetString(0)));
                    }
                    SqlDataReader dr3 = dl.LayTruongDuLieu("SELECT CMND FROM KHACHHANG WHERE MaKH='" + tatcakh[i] + "'");
                    while (dr3.Read())
                    {
                        lstr_cmnd.Add(dr3.GetString(0));
                    }
                    SqlDataReader dr4 = dl.LayTruongDuLieu("SELECT DiaChi FROM KHACHHANG WHERE MaKH='" + tatcakh[i] + "'");
                    while (dr4.Read())
                    {
                        lstr_diachi.Add(dr4.GetString(0));
                    }
                }
                KetNoi.NgatKetNoi();
            }
            catch { }
        }
    }
}
